package hxg.stream;

import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author HeXiangGuang
 * @create 2021-06-25 23:29
 * 使用字符缓冲流
 */
public class Demo5 {
    public static void main(String[] args) throws IOException {
//        Array
        FileOutputStream fos = new FileOutputStream("d:\\buffer.txt");
        BufferedOutputStream bos = new BufferedOutputStream(fos);
        for (int i = 0; i < 10; i++) {
            bos.write("helloworld\r\n".getBytes());//写入默认8kb缓存区
            bos.flush();//刷新到硬盘
        }
        //关闭（内部调用bos.flush()）
        bos.flush();
    }
}
